//
//  TabBarViewController.m
//  DanTang
//
//  Created by honeyrr on 2017/9/4.
//  Copyright © 2017年 honeyrr. All rights reserved.
//

#import "TabBarViewController.h"
#import "NavigationController.h"
#import "HomeViewController.h"
#import "ItemViewController.h"
#import "CategporyViewController.h"
#import "MyViewController.h"

@interface TabBarViewController ()

@end

@implementation TabBarViewController

+ (void)initialize
{
    NSDictionary *attrNormal = @{NSFontAttributeName:[UIFont systemFontOfSize:12],NSForegroundColorAttributeName:[UIColor grayColor]};
    NSDictionary *attrSelect = @{NSFontAttributeName:[UIFont systemFontOfSize:12],NSForegroundColorAttributeName:MRNavTabRGBColor};
    
    UITabBarItem *tbItem = [UITabBarItem appearance];
    [tbItem setTitleTextAttributes:attrNormal forState:UIControlStateNormal];
    [tbItem setTitleTextAttributes:attrSelect forState:UIControlStateSelected];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self allChildView];
}

- (void) allChildView
{
    [self addChildViewController:[HomeViewController new] tabBarItemTitle:@"首页" itemImgName:@"TabBar_home_23x23_" itemSelectedImgName:@"TabBar_home_23x23_selected"];
    [self addChildViewController:[ItemViewController new] tabBarItemTitle:@"单品" itemImgName:@"TabBar_gift_23x23_" itemSelectedImgName:@"TabBar_gift_23x23_selected"];
    [self addChildViewController:[CategporyViewController new] tabBarItemTitle:@"分类" itemImgName:@"TabBar_category_23x23_" itemSelectedImgName:@"TabBar_category_23x23_selected"];
    //[self addChildViewController:[MyViewController new] tabBarItemTitle:@"个人" itemImgName:@"TabBar_me_boy_23x23_" itemSelectedImgName:@"TabBar_me_boy_23x23_selected"];
}

-(void)addChildViewController:(UIViewController *)viewController tabBarItemTitle:(NSString *)title itemImgName:(NSString *)itemImgName itemSelectedImgName:(NSString *)itemSelectedImgName{
    
    UITabBarItem * messageItem = [[UITabBarItem alloc]initWithTitle:title image:[UIImage imageNamed:itemImgName] selectedImage:[[UIImage imageNamed:itemSelectedImgName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    
    viewController.tabBarItem = messageItem;
    NavigationController *navMessage = [[NavigationController alloc]initWithRootViewController:viewController];
    
    viewController.navigationItem.title = title;
    [self addChildViewController:navMessage];
}


@end
